#pragma once
#ifndef __G_SYNCHRONIZER_H__
#define __G_SYNCHRONIZER_H__

#include "GTypes.h"


namespace GThread
{
	#define G_MAX_WAIT_COUNT		10
	#define G_TIMEOUT_INFINITE		0xFFFFFFFF

	class GWaitable
	{
	public:
		virtual void*	GetHandle() const = 0;

	};

	enum GWaitResult
	{
		G_WR_ERROR			= 0,
		G_WR_TIMEOUT		= 1,
		G_WR_SIGNALED_0		= 2,
		G_WR_SIGNALED_1		= 3,
		G_WR_SIGNALED_2		= 4,
		G_WR_SIGNALED_3		= 5,
		G_WR_SIGNALED_4		= 6,
		G_WR_SIGNALED_5		= 7,
		G_WR_SIGNALED_6		= 8,
		G_WR_SIGNALED_7		= 9,
		G_WR_SIGNALED_8		= 10,
		G_WR_SIGNALED_9		= 11,
		G_WR_ABANDONED_0	= 12,
		G_WR_ABANDONED_1	= 13,
		G_WR_ABANDONED_2	= 14,
		G_WR_ABANDONED_3	= 15,
		G_WR_ABANDONED_4	= 16,
		G_WR_ABANDONED_5	= 17,
		G_WR_ABANDONED_6	= 18,
		G_WR_ABANDONED_7	= 19,
		G_WR_ABANDONED_8	= 20,
		G_WR_ABANDONED_9	= 21,
	};

	class GSynch
	{
	public:
		static GWaitResult		WaitFor(const GWaitable* Waitable, GUInt32 TimeOut = G_TIMEOUT_INFINITE);
		static GWaitResult		WaitFor(GWaitable* const* Waitables, GSize Count, bool WaitAll, GUInt32 TimeOut = G_TIMEOUT_INFINITE);

	};

};

#endif